layui.use(['jquery','element','form','layer','carousel'], function() {
    var $ = layui.$;
    var element = layui.element;
    var form = layui.form;
    var layer = layui.layer;
    var carousel = layui.carousel;

    //建造实例
    carousel.render({
        elem: '#test1'
        ,width: '90%' //设置容器宽度
        ,height: '100%' //设置容器宽度
        ,anim: 'default' //轮播切换动画方式
        ,arrow: 'hover' //始终显示箭头
        ,indicator: 'none' //指示器位置
    });

    form.render();
    form.on('submit(login)', function(data) {
        var loginArgs = {
            "loginName": $("input[name='loginName']").val(), 
            "loginPasswd": $("input[name='loginPasswd']").val()
        };
        console.log(loginArgs);

        $.post('ajaxChkLogin', loginArgs, function(result){
            if(result.success) {
                $(location).attr('href', 'portal');
            }
            else {
                layer.msg(result.data,{offset: 't'});
            }
        });
        return false;
    });

    layer.ready(function(){
        $("input[name='loginName']").focus();
    });
});